﻿using System;
using System.Collections.Generic;
using UnityEngine;

namespace ZZQFrameWork.AI
{
    #region 复合节点子节点

    /// <summary>
    /// 选择节点
    /// </summary>
    public class SelectorNode : CompositeNode
    {
        public override Enum_BTState Proc(EntityParent owner)
        {
            foreach (IBehaviorTreeNode node in childNodeList)
            {
                if(node.Proc(owner)==Enum_BTState.Success)return Enum_BTState.Success;
            }
            return Enum_BTState.Failure;
        }
    }

    /// <summary>
    /// 顺序节点
    /// </summary>
    public class SequenceNode : CompositeNode
    {
        public override Enum_BTState Proc(EntityParent owner)
        {
            //UnityEngine.Debug.Log("进入顺序节点！，有几个节点"+childNodeList.Count);
            foreach (IBehaviorTreeNode node in childNodeList)
            {
                if (node.Proc(owner) == Enum_BTState.Failure)
                {
                    //Debug.Log("检测失败");
                    return Enum_BTState.Failure;
                }
            }
            //Debug.Log("检测成功");
            return Enum_BTState.Success;
        }
    }

    /// <summary>
    /// 随机节点
    /// </summary>
    public class RandomNode : CompositeNode
    {
        public override Enum_BTState Proc(EntityParent owner)
        {
            if (childNodeList.Count < 0) return Enum_BTState.Failure;
            int i = UnityEngine.Random.Range(0, childNodeList.Count);
            return childNodeList[i].Proc(owner);
        }
    }

    #endregion

    public class CompositeNodes
    {
    }
}
